<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <div id="div1">
        <p id="div2">
            <span id="div3">
                <button>点击</button>
            </span>
        </p>
    </div>

    <script>
        var div1 = document.getElementById("div1");
        var div2 = document.getElementById("div2");
        var div3 = document.getElementById("div3");
        var btn = document.querySelector("button");
        
        div1.onclick = div3.onclick = btn.onclick = function(e){
            console.log(this.tagName);
        }

        div2.onclick = function(e){
            e.stopPropagation();
            console.log("p");
        }
        
    </script>
</body>

</html>
